<?php
namespace App\Jobs;

use App\Exceptions\InternalServerError;
use App\Facades\Warn;
use Exception;
use Log;

class BaseJob
{
    /**
     * 任务失败处理
     * @param Exception $e
     */
    public function failed(Exception $e)
    {
        $msg = ['errorMsg'=>$e->getMessage(), 'data'=>$this->data];

        $errorMsg = "Queue Failed :".json_encode($msg,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
        Log::error($errorMsg);
        $exception = new InternalServerError(50510,$errorMsg);
        Warn::warnMoSystem($exception);
    }

    public function msg($msg)
    {
        echo '['.date('Y-m-d H:i:s').'] '.$msg."\n";
    }
}
